<?php
function mkDirs($dir, $mode = 0775){
	if (is_dir($dir) || (@mkdir($dir) && chmod($dir, $mode)))
		return true;
	if (!mkDirs(dirname($dir), $mode))
		return false;
	return (@mkdir($dir) && chmod($dir, $mode));
}

function select($name, $options=Array(), $value=0, $attr=Array()) {
	foreach ($attr as $key=>$val) {
		$attributes .= "$key=\"$val\" ";
	}
	$html = "<select {$attributes}name=\"$name\">\n\t";
	if(!empty($options))
		foreach ($options as $key=>$val) {
			$html .= "\n\t<option value=\"$key\"".(($value == $key)?" selected=\"\"":null).">$val</option>";
		}
	$html .= "\n\t</select>\n";
	return $html;
}

function getThumb($url, $k) {
	$size = C('image_thumb_size');
	$subfix = $k ? (is_array($k) ? '_' . join('_', $k) : $k ) : '_thumb';
	return preg_replace('/\.(\w+)$/', $subfix . '\\0', $url);
}